<template>
  <div class="container">
    <!--菜单-->
    <MenuComponent  :onEvent="clickMenu" :selectCodeEvent="selectCodeHandle"/>

    <!--主页-->
    <component :is="currentPage"  @selectCode="handleSelectCode"/>

  </div>
</template>

<script >
import MenuComponent from "./components/base/MenuComponent.vue";
import KLinePage from "./components/KLinePage.vue";
import ReplayPage from "./components/ReplayPage.vue";
import KLine883957Page from "./components/KLine883957Page.vue";
import TimeChartPage from "./components/TimeChartPage.vue";
import AnalysisPage from "./components/AnalysisPage.vue";
import DataRecordListPage from "./components/DataRecordListPage.vue";
import OpenOrderPage from "./components/OpenOrderPage.vue";
import DoOrderPage from "./components/DoOrderPage.vue";
import TongDaXinPage from "./components/TongDaXinPage.vue";
import SetPage from "./components/SetPage.vue";
// import MessagePage from "./components/MessagePage.vue";
import HistoryDataShortQuickPage from "./components/HistoryDataShortQuickPage.vue";
import HistoryDataPage from "./components/HistoryDataPage.vue";
import DailyReviewPage from "./components/DailyReviewPage.vue";
import TimeChartZhiShuPage from "./components/TimeChartZhiShuPage.vue";


export default {
  components: { 
    MenuComponent, 
    KLinePage,
    ReplayPage,
    KLine883957Page,
    TimeChartPage,
    AnalysisPage,
    DataRecordListPage,
    OpenOrderPage,
    DoOrderPage,
    TongDaXinPage,
    SetPage,
    // MessagePage,
    HistoryDataShortQuickPage,
    HistoryDataPage,
    DailyReviewPage,
    TimeChartZhiShuPage,
  },
  data() {
    return {
      data:1,
      currentPage: "TimeChartZhiShuPage"
    }
  },
  methods: {
      clickMenu(value) {
          console.log("接收数据" + value)
          if (this.data !== value) {
            this.data = value
            console.log("接收数据" + this.data + (this.data == 1))
            if (this.data == 1) {
              this.currentPage = 'TimeChartZhiShuPage'
            } else if (this.data == 2){
              this.currentPage = 'TongDaXinPage'
            } else if (this.data == 3){
              this.currentPage = 'KLine883957Page'
            } else if (this.data == 4){
              this.currentPage = 'SetPage'
            }  else if (this.data == 5){
              this.currentPage = 'HistoryDataPage'
            }  else if (this.data == 6){
              this.currentPage = 'xx'
            } else if (this.data == 7){
              this.currentPage = 'DataRecordListPage'
            } else if (this.data == 8){
              this.currentPage = 'ReplayPage'
            } else if (this.data == 9){
              this.currentPage = 'HistoryDataShortQuickPage'
            } else if (this.data == 10){
              this.currentPage = 'TimeChartPage'
            }  else if (this.data == 11){
              this.currentPage = 'DoOrderPage'
            }         
          }
      },
      /**
       * 处理股票代码选择事件
       *
       * @param {string} value - 接收到的股票代码和名称，格式为"股票代码 股票名称"
       */
      selectCodeHandle(value) {
        
        const stockCode = value.split(' ')[0]
        const stockName = value.split(' ')[1]
        console.log("接收数据" +  stockCode + stockName)
        this.$store.dispatch('changeStockCode', stockCode);
        this.$store.dispatch('changeStockName', stockName);
      },

      handleSelectCode(data) {
        // console.log("接收数据历史" +  stockCode + stockName)
        this.$store.dispatch('changeStockCode', data.stockCode);
        this.$store.dispatch('changeStockName', data.stockName);
        this.$store.dispatch('changeStockTime', data.stockTime);
      },
  }
};
</script>

<style scoped>
.container {
    display: flex;
}

</style>



